#include "stdafx.h"
#include "GUI_CardPack.h"
#include"Entity.h"
#include"resource.h"
#include"TheRichMan.h"
#include"EntityPlayer.h"
GUI_CardPack::GUI_CardPack()
{
	inv_world = nullptr;
}


GUI_CardPack::~GUI_CardPack()
{
}

void GUI_CardPack::Init(Map & map, Entity & entity)
{
	inv_world = &entity.GetInventory(CardType::world);
	use_card = L"";
}

#include"DLGCardPack.h"
void GUI_CardPack::Launch(IGUIMgt & mgt)
{
	CDLGCardPack dlg;
	if (inv_world->IsValid())
	{
		int size = inv_world->GetMaxCapacity();
		for (int i = 0; i < size; i++)
		{
			auto card = inv_world->GetAt(i);
			if (card == L"")continue;
			dlg.cdc.Push(CardDraw(card));
		}
	}
	if (dlg.DoModal() == IDC_USE)
	{
		use_card = dlg.card;
	}
}

void GUI_CardPack::Update(Map & map, Entity & entity)
{
	if (use_card != L"")
	{
		if (&TheRichMan::instance.GetEntityPlayerOnThisRound() != &entity)return;
		TheRichMan::instance.WantUseCard(use_card);
	}
}
